package com.gxar.marketdelivery.domain.enums;

import com.gxar.marketdelivery.shared.meta.enums.IEnumItem;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * @author nice
 * @version 1.0
 * @created 2023/7/21.
 */
public enum DeliveryResSlotStatus implements IEnumItem<Integer, String> {
    CLOSE(0, "关闭"),
    OPEN(1, "开启");

    private Integer code;
    private String message;

    DeliveryResSlotStatus(Integer code, String message) {
        this.code = code;
        this.message = message;
    }


    private static Map<Integer, DeliveryResSlotStatus> ENUM_MAP = new HashMap<>();
    private static Map<Integer, String> CODE_MAP = new HashMap<>();

    static {
        for (DeliveryResSlotStatus status : values()) {
            ENUM_MAP.put(status.getCode(), status);
            CODE_MAP.put(status.getCode(), status.getMessage());
        }
    }


    public static boolean contains(Integer code) {
        return CODE_MAP.containsKey(code);
    }

    public static DeliveryResSlotStatus getByCode(Integer code) {
        return ENUM_MAP.get(code);
    }

    public static Map<Integer, String> getCodeMap() {
        return Collections.unmodifiableMap(CODE_MAP);
    }

    public static Map<Integer, DeliveryResSlotStatus> getEnumMap() {
        return Collections.unmodifiableMap(ENUM_MAP);
    }


    @Override
    public Integer getCode() {
        return this.code;
    }

    @Override
    public String getMessage() {
        return this.message;
    }
}
